package com.changpay.zywy.ui.activity.count
import android.view.View
import com.changpay.zywy.R
import com.changpay.zywy.base.BaseActivity
import com.changpay.zywy.base.IView
import com.changpay.zywy.ext.showToast
import com.changpay.zywy.ext.sss
import com.changpay.zywy.http.RetrofitHelper
import kotlinx.android.synthetic.main.activity_count_tai_jun_second.*
import kotlinx.android.synthetic.main.title_layout.*



class CountTaiJunSecondActivity : BaseActivity(), IView {
    private var member_id: String = ""
    private var goods_id: String = ""
    private var time: String = ""
    override fun showLoading() {

    }

    override fun hideLoading() {

    }

    override fun showDefaultMsg(msg: String) {
        showToast(msg)
    }

    override fun showMsg(msg: String) {
        showToast(msg)
    }

    override fun showError(errorMsg: String) {
        showToast(errorMsg)
    }


    private val onClickListener = View.OnClickListener { view ->
        when (view.id) {
            R.id.iv_back -> finish()
        }
    }

    override fun attachLayoutRes(): Int {
        return R.layout.activity_count_tai_jun_second
    }

    override fun initData() {

    }

    override fun initView() {
         member_id = intent.getStringExtra("member_id")
        goods_id = intent.getStringExtra("goods_id")
        time = intent.getStringExtra("time")
        tv_time.text = time + "台均统计"
        tv_title.text = "台均统计"
        iv_back.setOnClickListener(onClickListener)
    }

    override fun start() {
        val params = HashMap<String, String>()
        params["key"] = token
        params["member_id"] = member_id
        params["month"] = time
        params["goods_id"] = goods_id
        params["client"] = "android"
        RetrofitHelper.service.sn_average(params).sss(this)
        {
            tv_one.text =  it.result.list[0].num.toString() + "台"
            tv_two.text =  it.result.list[1].num.toString() + "台"
            tv_three.text =it.result.list[2].num.toString() + "台"
            tv_four.text = it.result.list[3].num.toString() + "台"
            tv_five.text = it.result.list[4].num.toString() + "台"
            tv_name_one.text = it.result.list[0].name.toString() + ": "
            tv_name_two.text = it.result.list[1].name.toString()+ ": "
            tv_name_three.text = it.result.list[2].name.toString()+ ": "
            tv_name_four.text = it.result.list[3].name.toString()+ ": "
            tv_name_five.text = it.result.list[4].name.toString()+ ": "
            val datas = mutableListOf<Int>()
            datas.add(it.result.list[0].num)
            datas.add(it.result.list[1].num)
            datas.add(it.result.list[2].num)
            datas.add(it.result.list[3].num)
            datas.add(it.result.list[4].num)
            fiveProgressView.setData(datas,it.result.total)
        }

    }


}
